Fix G004: replace logging f-strings with lazy % formatting#191
Open
Fix G004: replace logging f-strings with lazy % formatting#191
Conversation
Open
…om suppression list Agent-Logs-Url: https://github.com/GitHubSecurityLab/seclab-taskflow-agent/sessions/fc7d4cac-0cf0-4a55-b9a1-b00a172e1c03 Co-authored-by: kevinbackhouse <4358136+kevinbackhouse@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix linter error G004 and remove suppression from pyproject.toml
Fix G004: replace logging f-strings with lazy % formatting
Apr 2, 2026
kevinbackhouse
approved these changes
Apr 2, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the codebase to comply with Ruff rule G004 by replacing eager f-string interpolation inside logging calls with lazy %-style formatting, and then tightening linting by removing G004 from the Ruff ignore list.
Changes:
- Replaced
logging.*(f"...")calls withlogging.*("...%s...", ...)across affected modules. - Updated log message formatting to use
%s/%rplaceholders where appropriate. - Removed
G004frompyproject.toml’s Ruff ignore list to enforce the rule going forward.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/seclab_taskflow_agent/shell_utils.py | Uses lazy logging formatting for shell execution logs. |
| src/seclab_taskflow_agent/session.py | Converts session checkpoint and corrupt-file warnings to lazy formatting. |
| src/seclab_taskflow_agent/runner.py | Replaces multiple logging f-strings (critical/debug/error/exception/warning) with lazy formatting. |
| src/seclab_taskflow_agent/prompt_parser.py | Uses lazy formatting for parse errors and invalid global variable messages. |
| src/seclab_taskflow_agent/mcp_utils.py | Converts debug logs (including multiline debug output) to lazy formatting. |
| src/seclab_taskflow_agent/mcp_servers/codeql/client.py | Converts source prefix parsing error log to lazy formatting. |
| src/seclab_taskflow_agent/mcp_lifecycle.py | Uses lazy formatting for MCP lifecycle connect/cleanup and stream output logs. |
| src/seclab_taskflow_agent/agent.py | Updates hook lifecycle logging to lazy formatting and removes an extra trailing space. |
| pyproject.toml | Removes G004 from Ruff ignore list to enforce logging best practices. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ruff rule G004 flags f-strings in logging calls because string interpolation is eagerly evaluated even when the log level is disabled. This replaces all such f-strings with
%s-style lazy formatting across the codebase and removesG004from the suppression list inpyproject.toml.Changes
logging.*(f"...")→logging.*("...", ...)with%splaceholdersshell_utils.py,agent.py,prompt_parser.py,runner.py,session.py,mcp_utils.py,mcp_lifecycle.py,mcp_servers/codeql/client.pypyproject.toml— remove"G004"from[tool.ruff.lint] ignoreExample